package com.easyaccount.util;

import java.io.*;

public class FileUtils {


    public static void write(String filePth, InputStream in){
        File file = new File(filePth);
        File parentFile = file.getParentFile();
        if(!parentFile.exists()){
            parentFile.mkdirs();
        }

        FileOutputStream fout = null;
        try {
            fout = new FileOutputStream(filePth);
            byte[] b = new byte[1024];
            int len = -1;
            while ((len = in.read(b)) != -1){
                fout.write(b,0,len);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fout != null) {
                try {
                    fout.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}
